<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<?php  
 $this->headLink()->headLink(array('rel' => 'shortcut icon', 'href' => $this->baseUrl('public/images/favicon.ico')), 'PREPEND')
                  ->appendStylesheet($this->baseUrl('public/resource/kindeditor/index.css')) 
                  ->appendStylesheet($this->baseUrl('public/scripts/jquery/uploadify/uploadify.css')); 
 $this->headScript()->appendFile($this->baseUrl('public/resource/kindeditor/kindeditor.min.js'))
                    ->appendFile($this->baseUrl('public/scripts/jquery/jquery.min.js'))
                    ->appendFile($this->baseUrl('public/scripts/jquery/jquery.validate.min.js'))
                    ->appendFile($this->baseUrl('public/scripts/jquery/uploadify/swfobject.js')) 
                    ->appendFile($this->baseUrl('public/scripts/jquery/uploadify/jquery.uploadify.min.js')); 
echo $this->headLink(), $this->headScript();
?>

<title>发布留言</title>
<script type="text/javascript">
        
		
		KE.show({
				id : 'content',
				allowFileManager : true,
				afterCreate : function(id) {
					KE.event.ctrl(document, 13, function() {
						KE.util.setData(id);
						document.forms['example'].submit();
					});
					KE.event.ctrl(KE.g[id].iframeDoc, 13, function() {
						KE.util.setData(id);
						document.forms['example'].submit();
					});
				},
				items : [
				'fontname', 'fontsize', '|', 'textcolor', 'bgcolor', 'bold', 'italic', 'underline',
				'removeformat', '|', 'justifyleft', 'justifycenter', 'justifyright', 'insertorderedlist',
				'insertunorderedlist', '|', 'emoticons', 'link']
			});
			
			
			
		   //附件上传
			$(document).ready(function() {
				$("#file_upload").uploadify({
					'uploader'       : "<?php echo $this->baseUrl('public/scripts/jquery/uploadify/uploadify.swf')?>",
					'buttonImg'      : "<?php echo $this->baseUrl('public/scripts/jquery/uploadify/uploadify.jpg')?>",
					'script'         : "<?php echo $this->baseUrl('test/upfile/'); ?>",
					'cancelImg' 	 : "<?php echo $this->baseUrl('public/scripts/jquery/uploadify/cancel.png')?>",
					'folder'         : 'uploads',
					'queueID'        : 'fileQueue',
					'queueSizeLimit' : '5',
					'auto'			 : true,
					'multi'          : true,
					'fileExt'        : '*.jpg;*.gif;*.png;*.bmp;*.rar;*.zip;*.pdf',
					'fileDesc'		 : '请选择*.jpg;*.gif;*.png;*.bmp;*.rar;*.zip;*.pdf的文件',
					'sizeLimit'      : '3145725',
					'onComplete'     : function (e,queueId,fileObj,data) {
						data  =data.split("|");
						//添加到编辑器
						add_to_editor('content',data);
					}				
				});
			});
			//添加到编辑器
			function add_to_editor(id,data){
				var html;
				if (data[2] == 'img') {
					html = "<a href=\"<?php echo $this->baseUrl();?>/"+ data[1] +"\" target=\"_blank\"><img src=\"<?php echo $this->baseUrl();?>/"+ data[1] +"\" border='0'></a><br>";
				} else {
					html = "<a href=\"<?php echo $this->baseUrl();?>/"+ data[1] +"\" target=\"_blank\">"+data[0]+"</a><br/>";
				}
				KE.appendHtml(id, html);
				KE.layout.hide(id);
				KE.util.focus(id);		
			}	
			
		
		
        /*表单判断开始*/
		$(function() {
		    $("#captcha_div").hide();
			$("#captcha_input").focusin(function(){
			   $("#captcha_div").show();
			});
			$("#ff").validate({
				errorClass: "wrong",
				rules: {
					title: {required:true},
					content: {required:true},
					captcha_input: {required:true,remote:{
														url:"<?php echo $this->baseUrl('test/ajaxcaptcha/'); ?>",     
														type:"get",               
														dataType:"json",           
														data:{captcha_input:function(){ return $("#captcha_input").val();}}
                                                        														
													}
                              					
					}
				},
				messages: {
					title: {required:"标题不能为空"},
					content: {required:"内容不能为空"},
					captcha_input: {required:"请填写验证码",remote:"验证码有误"}
				}	
			});
			
         
		});

		/*表单判断结束*/




		//更换验证码（看不清，换一张）
		function sendcode(){
		  var iimg=document.getElementById("iimg");
		  iimg.src="<?php echo $this->baseUrl('test/imgcode/id/'); ?>" + Math.round(Math.random()*100000); //产生0-100000之间的随机整数
		}
		function refreshcode(){
		  document.getElementById("captcha_img").src="<?php echo $this->baseUrl('test/captcha/id/'); ?>" + Math.round(Math.random()*100000);
		  return false;
		}
</script>



<style>
table{border:1px solid #999999;}
td{vertical-align:middle; padding:5px 5px;}

label.wrong {
				padding:4px 4px 3px 20px;
				margin:2px 0;
				background-color: #FFFFFF;
				background-image: url(<?php echo $this->baseUrl('public/images/error.gif')?>);
				background-repeat: no-repeat;
				background-position: 4px;
				font-size: 12px;
				color:red;
		}
</style>



</head>

<body>
<div style="width:80%;margin:0 auto;">
<form method="post"action="<?php echo $this->baseUrl ?>/test/add/" name="ff" id="ff">   
<table style="width:80%" align="center">
	<thead>
	  <tr>
	    <th class="title" colspan="2">发布留言</th>
	  </tr>
	</thead>	
	<tbody>      
	  <tr>
	    <th style="width:25%;">标题</th>
		<td><input type="text" name="title" id="title" value="" size="20"/></td>
	  </tr>
	  <tr>
	    <th>内容</th>
		<td><textarea name="content" id="content" cols="70" rows="20"></textarea></td>
	  </tr>
	  
	  <tr>
	    <th>附件上传</th>
		<td>        <div id="fileQueue" style="float:left; width:100%;"></div>		
					<div style="float:left;margin-top:5px;">
                      <input id="file_upload" name="file_upload" type="file" />				
					</div>
		</td>
	  </tr>
	  
	  <!-- 备用验证码
	   <tr>
	    <th style="width:25%;">验证码</th>
		<td><input type="text" name="imgcode" id="imgcode" value="" size="4"/> 
		    <img src="<?php echo $this->baseUrl('test/imgcode/'); ?>" alt="看不清，换一张" name="iimg" align="absmiddle" id="iimg" style="cursor:pointer;" onclick="sendcode();" >
		</td>
	  </tr>
	  -->
	  <tr>
	    <th style="width:25%;" valign="top">验证码</th>
		<td><input type="text" name="captcha_input" id="captcha_input" size="4"/>
            <div id="captcha_div">		
		    <img src="<?php echo $this->baseUrl('test/captcha/'); ?>" id="captcha_img" name="captcha_img" alt="验证码" style="cursor:pointer;"   onclick="refreshcode();"/>
            </div>			
		</td>
	  </tr>
	  
	    <tr>
	    <th colspan="2"><input type="submit" value="发布" class="cmd" /></th>
	  </tr>
	  </tbody>
	</table>
</form>
</div>

</body>
</html>